/**
 * 格式化 localDate jdk8
 * @param {*} originVal
 */
export function localDateFormat(originVal) {
  if (originVal === null) {
    return null
  }
  const year = originVal[0]
  const month = (originVal[1] + '').padStart(2, '0')
  const day = (originVal[2] + '').padStart(2, '0')
  return `${year}-${month}-${day} `
}

/**
 *  格式化 localDateTime jdk8

 * @param {*} originVal 
 */
export function localDateTimeFormat(originVal) {
  const yearMonthDay = localDateFormat(originVal)

  const hh = (originVal.hour + '').padStart(2, '0')
  const mm = (originVal.minute + '').padStart(2, '0')
  const ss = (originVal.second + '').padStart(2, '0')
  return `${yearMonthDay} ${hh}:${mm}:${ss}`
}

/**
 * 格式化js Date
 * @param {*} originVal
 */
export function dateTimeFormat(originVal) {
  const dt = new Date(originVal)
  const year = dt.getFullYear()
  const month = (dt.getMonth() + 1 + '').padStart(2, '0')
  const day = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
}

export function dateFormat(originVal) {
  const dt = new Date(originVal)
  const year = dt.getFullYear()
  const month = (dt.getMonth() + 1 + '').padStart(2, '0')
  const day = (dt.getDate() + '').padStart(2, '0')

  return `${year}-${month}-${day} `
}
